# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=git-branchless
pkgver=0.3.12
pkgrel=0
pkgdesc="Suite of tools to help you visualize, navigate, manipulate, and repair your commit graph"
url="https://github.com/arxanas/git-branchless"
arch="aarch64 armhf armv7 ppc64le x86 x86_64"  # blocked by rust/cargo
license="GPL-2.0-only"
makedepends="
	cargo
	libgit2-dev
	libssh2-dev
	openssl-dev
	sqlite-dev
	"
checkdepends="git"
source="https://github.com/arxanas/git-branchless/archive/v$pkgver/git-branchless-$pkgver.tar.gz
	unbundle-sqlite.patch
	"

export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"
export CARGO_PROFILE_RELEASE_PANIC="abort"

export LIBSSH2_SYS_USE_PKG_CONFIG=1  # use system libssh2

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --frozen --release
}

check() {
	# NOTE: Skipped tests hang on CI, see
	#  https://github.com/arxanas/git-branchless/pull/159 for more info.
	TEST_GIT_EXEC_PATH=$(git --exec-path) \
	TEST_GIT=$(which git) \
	RUST_BACKTRACE=1 \
	cargo test --workspace --frozen -- \
		--skip=test_checkout_pty \
		--skip=test_next_ambiguous_interactive
}

package() {
	install -D -m755 target/release/git-branchless -t "$pkgdir"/usr/bin/
}

sha512sums="
6b09a419aba131dbf1ef15c157b9f795ce1c6d2435d6f6af54e78c68aaf7f9f3fa39374db45437d3ef022ae7106513e7b596a0f7c25051ad15422e9fed6b4423  git-branchless-0.3.12.tar.gz
b89b75f7ffe38d3b95f6ea1263993a5d6ea152b79a3acc5866f575361be7629f6e2c8f31e6d6d23b9a319bd217da5091dcc9d6a096069551ff972f19c090019f  unbundle-sqlite.patch
"
